home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 145 / Gekkan Dennou Club - 2000.6 Vol. 145 (Japan).7z / Gekkan Dennou Club - 2000.6 Vol. 145 (Japan) (Track 1).bin / tools / ex68 / ex68v205.lzh / X6_UTIL.LZH / GETROM.C next >
Text File  |  2000-04-03  |  977b  |  56 lines

  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <mem.h>
  5.  
  6. #define BUFFSIZE 0x4000
  7.  
  8. int exw(unsigned char *pt,int len,FILE *fp)
  9. {
  10. unsigned char *buff;
  11. int block;
  12. int total;
  13.     total=0;
  14.     buff=(unsigned char *)malloc(BUFFSIZE);
  15.     if (buff==NULL)
  16.         return -1;
  17.     while(len>0)
  18.     {
  19.         block=BUFFSIZE;
  20.         if (len<BUFFSIZE)
  21.             block=len;
  22.         memcpy(buff,pt,block);
  23.         if (fwrite(buff,1,block,fp)!=block)
  24.         {
  25.             free(buff);
  26.             return -1;
  27.         }
  28.         total+=block;
  29.         len-=block;
  30.         pt=&pt[block];
  31.     }
  32.     free(buff);
  33.     return total;
  34. }
  35.  
  36. void main()
  37. {
  38. FILE *fp;
  39.     fp=fopen("cg.rom","wb");
  40.     if (fp==NULL)    exit(1);
  41.     if (exw((unsigned char *)0xf00000,0xc0000,fp) != 0xc0000)
  42.         exit(1);
  43.     fclose(fp);
  44.     
  45.     fp=fopen("boot.rom","wb");
  46.     if (fp==NULL)    exit(1);
  47.     if (exw((unsigned char *)0xfe0000,0x20000,fp) != 0x20000)
  48.         exit(1);
  49.     
  50.     fp=fopen("sram.ram","wb");
  51.     if (fp==NULL)    exit(1);
  52.     if (exw((unsigned char *)0xed0000,0x4000,fp) != 0x4000)
  53.         exit(1);
  54.     fclose(fp);
  55. }
  56.